package com.cai.oamanager.config;

import com.cai.oamanager.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * @version 1.0
 * @author：蔡松坡
 * @date：2021/1/16 10 : 53
 * @package：com.cai.oamanager.config
 */
@Configuration
public class MyConfig extends WebMvcConfigurerAdapter {

    @Autowired
    private UserService userService;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("进入路径设置");
        List pathList = new ArrayList();
        pathList.add("/router/login.html");
        pathList.add("/login/login");
        registry.addInterceptor(new MyIntercepter(userService))
                .addPathPatterns("/*")
                .excludePathPatterns(pathList);
    }
}
